<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>三次贝塞曲线</title>
</head>
<body>
<canvas id="c1" width="600" height="400" style="border:1px solid #d3d3d3;">
    您的浏览器不支持 HTML5 canvas 标签。
</canvas>
<script>
    var canvas = document.getElementById('c1');
    var ctx = canvas.getContext('2d');

    // 开始新路径
    ctx.beginPath();
    // 移动到起点
    ctx.moveTo(100, 150);
    // 绘制三次贝塞尔曲线
    ctx.bezierCurveTo(150, 100, 200, 200, 250, 150);
    // 描边路径
    ctx.stroke();

    ctx.strokeStyle = 'red';
    ctx.beginPath();
    ctx.moveTo(100, 150);
    ctx.lineTo(150, 100)
    ctx.lineTo(200, 200)
    ctx.lineTo(250, 150)
    ctx.stroke()
    ctx.closePath()
</script>
</body>
</html>
